package com.qch.leecode.cyc2018.util_comom;

/**
 * @Author qch
 * @Date 2022/11/7
 */
public class Common {
    public static String toString(int[] m){
        String str="{";
        for (int i=0;i<m.length ; i++) {
            str+=m[i]+",";
        }
        String s=str.substring(0,str.length()-1)+"}";
        System.out.println(s);
        return s;
    };

    //二维数组打印
    public static String toString(int[][] m){
        String str="{";
        for (int i = 0; i < m.length; i++) {
            str+=toString(m[i])+"，";
        }
        String s=str.substring(0,str.length()-1)+"}";
        System.out.println(s);
        return s;
    };

    /**
     * [[3,9],[7,12],[3,8],[6,8],[9,10],[2,9],[0,9],[3,9],[0,6],[2,8]]
     * 替换
     */
    public static String replace(String s,String old,String now){

      String s1= s.replaceAll(old,now);
       // System.out.println(s1);
        return s1;
    };

    public static  String rezkuohao(String s) {
        String replace = replace(s, "\\[", "\\{");
        String replace2 = replace(replace, "\\]", "\\}");
        System.out.println(replace2);
        return replace2;
    }

    public static void main(String[] args) {
        String s="[[1,9],[7,16],[2,5],[7,12],[9,11],[2,10],[9,16],[3,9],[1,3]]";
        rezkuohao(s);
    }
}
